﻿/// <reference path="~/Scripts/lib/jquery-1.8.3.js" />
/// <reference path="~/Scripts/lib/knockout-2.2.0.js" />
/// <reference path="config.js" />
/// <reference path="vm.js" />

/**
 @title:        binder
 @description:  Binds view-model to view. Expose bind namespace. 
                Finds and returns a view by ids list in config.
 @author:       Yuriy Shapovalov (shapovalov.yuri@gmail.com)
 */

define('binder',
    ['jquery', 'ko', 'config', 'vm'],
    function ($, ko, config, vm) {
        var
            ids = config.viewIds,

            bind = function () {
                debugger // check that view expect such view model
                ko.applyBindings(vm.workspace, getView(ids.workspace));
            },

            getView = function (viewName) {
                return $(viewName).get(0);
            };
        return {
            bind: bind
        };
    });